home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / gcc260utilsdoc.lha / gnu / man / man1 / sort.1 < prev    next >
Encoding:
Text File  |  1994-07-26  |  9.3 KB  |  265 lines

  1.  
  2.  
  3.  
  4. SORT(1L)          Misc. Reference Manual Pages           SORT(1L)
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      sort - sort lines of text files
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ssssoooorrrrtttt [-cmus] [-t separator] [-o output-file] [-T tempdir] [-
  13.      bdfiMnr] [+POS1 [-POS2]] [-k POS1[,POS2]] [file...]
  14.      ssssoooorrrrtttt {--help,--version}
  15.  
  16. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.      This manual page documents the GNU version  of  ssssoooorrrrtttt.   ssssoooorrrrtttt
  18.      sorts,  merges,  or  compares  all  the lines from the given
  19.      files, or the standard input if no files are given.  A  file
  20.      name  of  `-' means standard input.  By default, ssssoooorrrrtttt writes
  21.      the results to the standard output.
  22.  
  23.      ssssoooorrrrtttt has three  modes  of  operation:  sort  (the  default),
  24.      merge,  and  check  for  sortedness.   The following options
  25.      change the operation mode:
  26.  
  27.      -_c    Check whether the given files are already  sorted:  if
  28.           they  are  not  all  sorted, print an error message and
  29.           exit with a status of 1.
  30.  
  31.      -_m    Merge the given files by  sorting  them  as  a  group.
  32.           Each  input file should already be individually sorted.
  33.           It always works to sort instead of  merge;  merging  is
  34.           provided  because  it  is  faster, in the case where it
  35.           works.
  36.  
  37.      A pair of lines is compared as follows: if  any  key  fields
  38.      have  been  specified, ssssoooorrrrtttt compares each pair of fields, in
  39.      the order specified on the command line,  according  to  the
  40.      associated  ordering options, until a difference is found or
  41.      no fields are left.
  42.  
  43.      If any of the global options _M_b_d_f_i_n_r are given  but  no  key
  44.      fields are specified, ssssoooorrrrtttt compares the entire lines accord-
  45.      ing to the global options.
  46.  
  47.      Finally, as a last resort when all keys compare equal (or if
  48.      no  ordering  options  were specified at all), ssssoooorrrrtttt compares
  49.      the lines byte by byte in machine collating  sequence.   The
  50.      last  resort comparison honors the -_r global option.  The -_s
  51.      (stable) option disables this last-resort comparison so that
  52.      lines  in  which  all fields compare equal are left in their
  53.      original relative order.  If no fields or global options are
  54.      specified, -_s has no effect.
  55.  
  56.      GNU ssssoooorrrrtttt has no limits on input line length or  restrictions
  57.      on  bytes  allowed  within lines.  In addition, if the final
  58.      byte of an input file is not a newline,  GNU  ssssoooorrrrtttt  silently
  59.      supplies one.
  60.  
  61.  
  62.  
  63. FSF              Last change: GNU Text Utilities                1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SORT(1L)          Misc. Reference Manual Pages           SORT(1L)
  71.  
  72.  
  73.  
  74.      If the environment variable TTTTMMMMPPPPDDDDIIIIRRRR is set, ssssoooorrrrtttt uses  it  as
  75.      the directory in which to put temporary files instead of the
  76.      default, /tmp.  The -_T _t_e_m_p_d_i_r  option  is  another  way  to
  77.      select  the  directory for temporary files; it overrides the
  78.      environment variable.
  79.  
  80.      The following options affect the ordering of  output  lines.
  81.      They  may be specified globally or as part of a specific key
  82.      field.  If no key fields are specified, global options apply
  83.      to  comparison of entire lines; otherwise the global options
  84.      are inherited by key fields that do not specify any  special
  85.      options of their own.
  86.  
  87.      -_b    Ignore leading blanks when finding sort keys  in  each
  88.           line.
  89.  
  90.      -_d    Sort in `phone directory' order: ignore all characters
  91.           except letters, digits and blanks when sorting.
  92.  
  93.      -_f    Fold lower case characters into the  equivalent  upper
  94.           case  characters when sorting so that, for example, `b'
  95.           is sorted the same way `B' is.
  96.  
  97.      -_i    Ignore characters outside  the  ASCII  range  040-0176
  98.           octal (inclusive) when sorting.
  99.  
  100.      -_M    An initial string, consisting of any amount  of  white
  101.           space,  followed  by three letters abbreviating a month
  102.           name, is folded to UPPER case and compared in the order
  103.           `JAN' < `FEB' < ... < `DEC.'  Invalid names compare low
  104.           to valid names.
  105.  
  106.      -_n    Compare  according  to  arithmetic  value  an  initial
  107.           numeric  string  consisting of optional white space, an
  108.           optional - sign, and zero or  more  digits,  optionally
  109.           followed by a decimal point and zero or more digits.
  110.  
  111.      -_r    Reverse the result of comparison, so that  lines  with
  112.           greater key values appear earlier in the output instead
  113.           of later.
  114.  
  115.      Other options are:
  116.  
  117.      -_o _o_u_t_p_u_t-_f_i_l_e
  118.           Write output to _o_u_t_p_u_t-_f_i_l_e instead of to the  standard
  119.           output.  If _o_u_t_p_u_t-_f_i_l_e is one of the input files, ssssoooorrrrtttt
  120.           copies it to a temporary file before sorting and  writ-
  121.           ing the output to _o_u_t_p_u_t-_f_i_l_e.
  122.  
  123.      -_t _s_e_p_a_r_a_t_o_r
  124.           Use character _s_e_p_a_r_a_t_o_r as  the  field  separator  when
  125.           finding the sort keys in each line.  By default, fields
  126.  
  127.  
  128.  
  129. FSF              Last change: GNU Text Utilities                2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SORT(1L)          Misc. Reference Manual Pages           SORT(1L)
  137.  
  138.  
  139.  
  140.           are separated  by  the  empty  string  between  a  non-
  141.           whitespace  character and a whitespace character.  That
  142.           is to say, given the input line ` foo bar', ssssoooorrrrtttt breaks
  143.           it  into fields ` foo' and ` bar'.  The field separator
  144.           is not considered  to  be  part  of  either  the  field
  145.           preceding or the field following it.
  146.  
  147.      -_u    For the default case or the -_m option, only output the
  148.           first  of  a sequence of lines that compare equal.  For
  149.           the -_c option, check that no pair of consecutive  lines
  150.           compares equal.
  151.  
  152.      +_P_O_S_1 [-_P_O_S_2]
  153.           Specify a field within each line to use  as  a  sorting
  154.           key.   The  field  consists  of the portion of the line
  155.           starting at POS1 and up to (but not including) POS2 (or
  156.           to  the  end  of  the  line if POS2 is not given).  The
  157.           fields and character positions  are  numbered  starting
  158.           with 0.
  159.  
  160.      -_k _P_O_S_1[,_P_O_S_2]
  161.           An alternate syntax for specifying sorting  keys.   The
  162.           fields  and  character  positions are numbered starting
  163.           with 1.
  164.  
  165.      A position has the form _f._c, where _f is the  number  of  the
  166.      field to use and _c is the number of the first character from
  167.      the beginning of the field (for +_p_o_s) or from the end of the
  168.      previous field (for -_p_o_s).  The ._c part of a position may be
  169.      omitted in which case it is taken to be the first  character
  170.      in  the field.  If the -_b option has been given, the ._c part
  171.      of a field specification is counted from the first  nonblank
  172.      character of the field (for +_p_o_s) or from the first nonblank
  173.      character following the previous field (for -_p_o_s).
  174.  
  175.      A +_p_o_s or -_p_o_s argument may also  have  any  of  the  option
  176.      letters  _M_b_d_f_i_n_r  appended  to  it, in which case the global
  177.      ordering options are not used  for  that  particular  field.
  178.      The   - _b  option may be independently attached to either or
  179.      both of the +_p_o_s and -_p_o_s parts of  a  field  specification,
  180.      and  if  it  is inherited from the global options it will be
  181.      attached to both.  If a -_n or -_M option is used, thus imply-
  182.      ing a -_b option, the -_b option is taken to apply to both the
  183.      +_p_o_s and the -_p_o_s parts of a key  specification.   Keys  may
  184.      span multiple fields.
  185.  
  186.      In addition, when GNU jjjjooooiiiinnnn is invoked with exactly one argu-
  187.      ment, the following options are recognized:
  188.  
  189.      --_h_e_l_p
  190.           Print a usage message on standard output and exit  suc-
  191.           cessfully.
  192.  
  193.  
  194.  
  195. FSF              Last change: GNU Text Utilities                3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. SORT(1L)          Misc. Reference Manual Pages           SORT(1L)
  203.  
  204.  
  205.  
  206.      --_v_e_r_s_i_o_n
  207.           Print version information on standard output then  exit
  208.           successfully.
  209.  
  210. CCCCOOOOMMMMPPPPAAAATTTTIIIIBBBBIIIILLLLIIIITTTTYYYY
  211.      Historical (BSD and System V) implementations of  ssssoooorrrrtttt  have
  212.      differed  in  their interpretation of some options, particu-
  213.      larly -_b, -_f, and -_n.  GNU sort follows the POSIX  behavior,
  214.      which  is  usually  (but  not  always!)  like  the  System V
  215.      behavior.  According to POSIX -_n no longer implies -_b.   For
  216.      consistency,  -_M has been changed in the same way.  This may
  217.      affect the meaning of character positions in field  specifi-
  218.      cations  in  obscure cases.  If this bites you the fix is to
  219.      add an explicit -_b.
  220.  
  221. BBBBUUUUGGGGSSSS
  222.      The different meaning of field numbers depending on  whether
  223.      -_k is used is confusing.  It's all POSIX's fault!
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. FSF              Last change: GNU Text Utilities                4
  262.  
  263.  
  264.  
  265.